package com.gzxxgl.util;

import java.io.*;
import java.util.*;

import org.apache.commons.lang3.StringUtils;
import org.dom4j.*;
import org.dom4j.io.*;

import com.jfinal.kit.PathKit;

public class MyXMLReader2DOM4J {
	@SuppressWarnings({ "rawtypes" })
	public static List<String> getIPs() {
		List<String> ls = new ArrayList<String>();
		long lasting = System.currentTimeMillis();
		try {
			File f = new File(PathKit.getRootClassPath()+"/LockIP.xml");
			SAXReader reader = new SAXReader();
			Document doc = reader.read(f);
			Element root = doc.getRootElement();
			Element foo;
			for (Iterator i = root.elementIterator("VALUE"); i.hasNext();) {
				foo = (Element) i.next();
				// Attribute item = foo.attribute("name");// 获取<line>元素的属性  
				String s = foo.elementText("ip");
				if(StringUtils.isNotEmpty(s)){
					ls.add(s);
				}
              System.out.println("ip:"+foo.elementText("ip")); 
			}
			System.out.println("运行时间：" + (System.currentTimeMillis() - lasting) + "毫秒");

		} catch (Exception e) {
			e.printStackTrace();
		}
		return ls;
	}
	public static void main(String arge[]) {
		getIPs();
	}
}